<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>${message("编辑会员")}</title>
<link href="/resources/css/common.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="/resources/js/reference/jquery.js"></script>
<script type="text/javascript" src="/resources/js/reference/jquery.validate.js"></script>
<script type="text/javascript" src="/resources/js/base/dialog.js"></script>
<script type="text/javascript" src="/resources/js/base/request.js"></script>
<script type="text/javascript" src="/resources/js/base/global.js"></script>
<script type="text/javascript" src="/resources/plugin/datePicker/WdatePicker.js"></script>
<link href="/resources/css/mmGrid.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="/resources/js/reference/mmGrid.js"></script>
<script src="/resources/js/base/file.js"></script>
<script type="text/javascript">
$().ready(function() {
	$("#password").val("");
	var $inputForm = $("#inputForm");

	// 表单验证
	$inputForm.validate({
		rules: {
			mobile: {
				required:true
			},
			password: {
				pattern: /^[^\s&\"<>]+$/,
				minlength: ${setting.passwordMinLength},
				maxlength: ${setting.passwordMaxLength}
			},
			rePassword: {
				equalTo: "#password"
			},
			pinCode: {
				required: function(){
					var isRequest = $("input[name='memberType']:checked").val();
					isRequest = isRequest==1?true:false;
					return isRequest;
				},
				pattern: /^\w+$/,
				minlength: 6,
				maxlength: 6
			},
			operatePassword: {
				required: function(){
					var isRequest = $("input[name='memberType']:checked").val();
					isRequest = isRequest==1?true:false;
					return isRequest;
				},
				pattern: /^[^\s&\"<>]+$/,
				minlength: 6,
				maxlength: 6
			}
		},
		messages: {
			password: {
				pattern: "${message("非法字符")}"
			},
			pinCode: {
				pattern: "${message("非法字符")}"
			},
			operatePassword: {
				pattern: "${message("非法字符")}"
			}
			[#if !setting.isDuplicateEmail]
				,email: {
					remote: "${message("已存在")}"
				}
			[/#if]
		},
		submitHandler:function(form){
			return false;
		}
	});
	
	$.validator.addClassRules({
		psw:{
			required: true
		}
	});
	
	var terminalInItemIndex = 0;
	 [#if terminals!=null]
		var terminals = ${terminals};
	[#else]
		var terminals = {};
	[/#if]
	var cols = [				
   	{ title:'${message("终端设备编号")}', name:'terminalNum' ,align:'center', width:110, renderer: function(val,item,rowIndex, obj){
			var	html = '<input type="hidden" name="terminalId" class="terminalId terminalId_'+item.id+'" value="'+item.id+'" />'+val;
			return html;}
		},
   	{ title:'${message("终端名称")}', name:'terminalName' ,align:'center', width:110},
   	{ title:'${message("终端SIM卡号")}', name:'sim' ,align:'center', width:110},
		{ title:'${message("操作")}', align:'center', width:60, renderer:function(val,item){
		terminalInItemIndex++;
		return '<a href="javascript:;" class="deleteTerminal btn-delete">删除</a>';
		}},
	];
	var $tmGrid=$('#table-terminal').mmGrid({
		fullWidthRows:true,
		height:'auto',
       cols: cols,
       checkCol: false,
       items:terminals,
       autoLoad: true,
   });
	
	//查询机构
	$("#selectSaleOrg").bindQueryBtn({
		type:'saleOrg',
		title:'${message("查询机构")}',
		url:'/saleOrg/select_saleOrg.jhtml'
	});	
	
	$("form").bindAttribute({
		callback: function(msgResult){
			cancle_iframe()
		}
	});
	
	$("form").bindAttribute({
		isConfirm:true,
	    callback: function(resultMsg){
	        $.message_timer(resultMsg.type,resultMsg.content,1000,function(){
				location.reload(true);
			});
	    }
	 });
	//改变用户类型
    $("input[name='memberType']").live("click", function() {
    	var rs = $(this).val();
    	if(rs==1){
    		$("#pinCode").addClass("psw");
    		$("#operatePassword").addClass("psw");
    	}else{
    		$("#pinCode").removeClass("psw");
    		$("#operatePassword").removeClass("psw");
    	}
    	
    });
});

</script>
</head>
<body>
	<div class="pathh">
		&nbsp;${message("查看用户")}
	</div>
	<form id="inputForm" action="update_info.jhtml" method="post" type="ajax" validate-type="validate">
		<input type="hidden" name="id" value="${member.id}" />
		<ul id="tab" class="tab">
			<li>
				<input type="button" value="${message("12133")}" class="current"/>
			</li>
		</ul>
		<div class="tabContent">
			<table class="input input-edit">
			<tr>
				<th>
					${message("15023")}:
				</th>
				<td>
					${member.username}
				</td>
				<th>
					<span class="requiredField">*</span>${message("手机")}:
				</th>
				<td>
					${member.mobile}
				</td>
				<th>
					${message("登录密码")}:
				</th>
				<td>
					<span class="error-msg"><input type="text" id="password" name="password" value="" class="text" maxlength="20"  btn-fun="clear" autocomplete="off" onfocus="this.type='password'"/></span>
				</td>
				<th>
					${message("确认登录密码")}:
				</th>
				<td>
					<span class="error-msg"><input type="text" name="rePassword" class="text" maxlength="20"  btn-fun="clear" autocomplete="off" onfocus="this.type='password'"/></span>
				</td>
			</tr>
			<tr>
				<th>
					<span class="requiredField"></span>${message("机构")}:
				</th>
				<td>
					<span class="search" style="position:relative">
					<input type="hidden" name="saleOrgId" class="text saleOrgId" btn-fun="clear" [#if saleOrg??]value="${saleOrg.id}"[/#if]/>
					<input type="text" name="saleOrgName" class="text saleOrgName" maxlength="200" onkeyup="clearSelect(this)" value="[#if saleOrg??]${saleOrg.name}[/#if]" readOnly/>
					<input type="button" class="iconSearch" value="" id="selectSaleOrg">
					</span>
				</td>
				<!--<th>
					${message("12500")}:
				</th>
				<td>
					<span class="search" style="position:relative">
						<input type="hidden" name="memberRankId" class="text memberRankId" id="memberRankId" btn-fun="clear" value="${store_member.memberRank.id}" />
						<input type="text" name="memberRankName" class="text memberRankName" maxlength="200" onkeyup="clearSelect(this)" id="memberRankName" value="${store_member.memberRank.name}" />
						<input type="button" class="iconSearch" value="" id="selectMemberRank">
					</span>
				</td>-->
				<th>
					${message("姓名")}:
				</th>
				<td>
					<input type="text" name="name" class="text" value="${member.name}" maxlength="200"  btn-fun="clear"/>
				</td>
				<th>
					${message("用户类型")}:
				</th>
				<td>
					<label><input type="radio" name="memberType" value="0" [#if member.memberType==0]checked="checked"[/#if] />业务系统用户</label>
					<label><input type="radio" name="memberType" value="1" [#if member.memberType==1]checked="checked"[/#if] />操作终端用户</label>
				</td>
				<th>
				</th>
				<td>
				</td>
			</tr>
			<!--<tr>
				<th>
					${message("用户余额")}:
				</th>
				<td>
					<span style="color:#f60;">${currency(store_member.balance, true)}</span>
				</td>
				<th>
					${message("用户收益")}:
				</th>
				<td>
					<span style="color:#f60;">${currency(store_member.income!0, true)}</span>
				</td>
				<th class="noBg"></th><td></td>
				<th class="noBg"></th><td></td>
			</tr>-->
			<tr>
				<th>
					${message("操作员PIN码")}:
				</th>
				<td>
					<span class="error-msg"><input type="text" id="pinCode" name="pinCode" value="${member.pinCode}" class="text [#if member.memberType==1]psw[/#if]" maxlength="20"   btn-fun="clear"/></span>
				</td>
				<th>
					${message("操作终端密码")}:
				</th>
				<td>
					<span class="error-msg">
					<input type="password"  style="display:none"/>   
					<input type="text" id="operatePassword" name="operatePassword" value="${member.operatePassword}" class="text [#if member.memberType==1]psw[/#if]" maxlength="20" btn-fun="clear" autocomplete="off" /></span>
				</td>
				<th>
					${message("16035")}:
				</th>
				<td colspan="3">
					<label>
						<input type="checkbox" name="isEnabled" value="true"[#if member.isEnabled] checked="checked"[/#if] />${message("16045")}
						<input type="hidden" name="_isEnabled" value="false" />
					</label>&nbsp;&nbsp;&nbsp;
					<label [#if isAdmin!="true"]style="display:none"[/#if]>
						<input type="checkbox" name="isAdministrator" value="true" [#if isAdministrator] checked="checked"[/#if] />${message("是否有查询所有客户权限")}
						<input type="hidden" name="_isAdministrator" value="false" />
					</label>&nbsp;&nbsp;&nbsp;
					
					[#if store_member.member.isLocked]
						<label>
							<input type="checkbox" name="isLocked" value="true" checked="checked" />${message("Member.isLocked")}
							<input type="hidden" name="_isLocked" value="false" />
						</label>&nbsp;&nbsp;&nbsp;
					[/#if]
					<!-- <label>
						<input type="checkbox" name="isPartner" value="true"[#if store_member.isPartner] checked="checked"[/#if] /><span class="green">${message("16088")}</span>
						<input type="hidden" name="_isPartner" value="false" />
					</label>&nbsp;&nbsp;&nbsp; -->
					<input type="hidden" name="isPartner" value="false" />
				</td>
			</tr>
			<tr id ="role_type">
				<th>
					${message("所属角色")}:
				</th>
				<td colspan="7">
					<span class="fieldSet">
						[#list roles as role]
							<label>
								<input  id="roleId" type="checkbox" name="roleId" value="${role.id}"[#if uRoles?seq_contains(role)] checked="checked"[/#if] />${role.name}
							</label>&nbsp;&nbsp;&nbsp;
						[/#list]
					</span>
				</td>
			</tr>
			<!-- <tr>
				<th>${message("头像")}</th>
				<td colspan="7"><input type="hidden" name="imageName" value="${member.imageName}" ></td>
			</tr> -->
			<tr class="border-L2">
                <th>${message("操作终端设备")}:</th>
                <td colspan="7">
                </td>
            </tr>
           <tr class="border-L2">
            	<td colspan="8">
            		<div>
						<table id="table-terminal"></table>
					</div>
            	</td>
            </tr>
			</tr>
		</table>
		</div>
		<div class="fixed-top">
			<input type="submit" id="submit_button" class="button sureButton" value="${message("1013")}" />
			<input type="button" class="button backButton" value="${message("1014")}" onclick="cancle_iframe();" />
		</div>
	</form>
</body>
</html>